package com.zone.baseproject.utils;

import android.app.ProgressDialog;
import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;

import com.zone.baseproject.R;


/**
 * Created by john on 2016/8/15.
 */
public class DialogUtils {

    private static AlertDialog.Builder builder;
    private static AlertDialog dialog;

    public interface Convert{
        void transaction(View dialogView, AlertDialog alertDialog);
    }

    static ProgressDialog progressDialog;
    public static void showProgressDialog(Context context, String message){
        if (progressDialog == null) {
            progressDialog = new ProgressDialog(context);
            progressDialog.setMessage(message);
            progressDialog.setCanceledOnTouchOutside(false);
        }
        progressDialog.show();
    }
    public static void hideProgressDialog(){
        if (progressDialog != null) {
            progressDialog.dismiss();
        }
    }



    public static void hideAnimiDialog() {
        if (dialog != null) {
            dialog.dismiss();
        }
    }



    public static void showLoginDialog(final Context context, int layoutId, Convert convert){
        View dialogView = LayoutInflater.from(context).inflate(layoutId, null);
        builder = new AlertDialog.Builder(context);
        AlertDialog dialog=builder.create();
        dialog.setView(dialogView,0,0,0,0);
        convert.transaction(dialogView,dialog);
        dialog.show();
    }


}
